package MyJava;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;

@WebFilter(filterName = "AllFilter")
@WebServlet("AllFilter")
public class AllFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest req= (HttpServletRequest) request;
        HttpServletResponse res= (HttpServletResponse) response;

        HttpSession httpSession=req.getSession();
        if(httpSession.getAttribute("userName")==null)
        {
            //res.sendRedirect("index.html");
        }
        else
        {
            //res.sendRedirect("show.jsp");
        }
        chain.doFilter(req,res);
    }

    @Override
    public void destroy() {

    }
}